package wh.coach._string;

/**
 * @author hangwen
 * @date 2023/6/23
 */
public class _Concat {
    public static void main(String[] args) {
        String str1 = "hello";
        String str2 = "world";
//        String str_2_5 = str1 + " ";
        String str3 = str1 + " " + str2;

        //java 9之后，对于+连接常量的时候，编译器会优化
        StringBuilder sb = new StringBuilder();
        String str4 = sb.append(str1).append(" ").append(str2).toString();

        //不建议用
        StringBuffer stringBuffer = new StringBuffer();

        //实践可用+，1.少量、简短字符串；2.常量

        //还有哪些？
        final String join = String.join("|", str1, str2, str1);
        System.out.println(join);
    }
}
